package com.example.demo_scan;

import android.content.Intent;
import android.hardware.SensorManager;
import android.view.View;
import android.widget.ImageButton;

import androidx.annotation.NonNull;

import com.mylhyl.zxing.scanner.ScannerView;

import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;

/** DemoScanPlugin */
public class DemoScanPlugin implements FlutterPlugin, MethodCallHandler {

  private MethodChannel channel;

  @Override
  public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
    channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "demo_scan");
    channel.setMethodCallHandler(this);
  }

  @Override
  public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
//    System.out.print(call.method);
//    if (call.method.equals("scan")) { // 扫码
//      this.result = result;
//      Intent intent = new Intent(mActivity, QRCodeActivity.class);
//      mActivity.startActivity(intent);
//      result.success("跳转");
//    } else if (call.method.equals("getPlatformVersion")) {
//      result.success("Android " + android.os.Build.VERSION.RELEASE);
//    } else if (call.method.equals("dismiss")) { // 返回方法
//
//    } else {
//      result.notImplemented();
//    }
  }

  @Override
  public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
    channel.setMethodCallHandler(null);
  }

}
